package com.wgn.reportquery.rj.model;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class RJReportInfo implements Comparable {

	public String getBgdh() {
		return bgdh;
	}

	public void setBgdh(String bgdh) {
		this.bgdh = bgdh;
	}

	public String getYymc() {
		return yymc;
	}

	public void setYymc(String yymc) {
		this.yymc = yymc;
	}

	public String getBgrq() {
		return bgrq;
	}

	public void setBgrq(String bgrq) {
		this.bgrq = bgrq;
	}

	public String getBbmc() {
		return bbmc;
	}

	public void setBbmc(String bbmc) {
		this.bbmc = bbmc;
	}

	public String getBgdlb() {
		return bgdlb;
	}

	public void setBgdlb(String bgdlb) {
		this.bgdlb = bgdlb;
	}

	String bgdh, yymc, bgrq, bbmc, bgdlb;

	@Override
	public int compareTo(Object o) {
		// TODO Auto-generated method stub

		RJReportInfo rinof = (RJReportInfo) o;

		// note: enum-type's comparation depend on types' list order of enum
		// method
		// so, if compared property is enum-type ,then its comparationfollow
		// ObjEnum.objType order

		return compare_date(rinof.getBgrq(), this.getBgrq());
	}

	public static int compare_date(String DATE1, String DATE2) {
		DateFormat df = new SimpleDateFormat("yyyyMMdd");
		try {
			Date dt1 = df.parse(DATE1);
			Date dt2 = df.parse(DATE2);
			if (dt1.getTime() > dt2.getTime()) {
				// System.out.println("dt1 在dt2前");
				return 1;
			} else if (dt1.getTime() < dt2.getTime()) {
				// System.out.println("dt1在dt2后");
				return -1;
			} else {
				return 0;
			}
		} catch (Exception exception) {
			exception.printStackTrace();
		}
		return 0;
	}
}
